object frmDM: TfrmDM
  OldCreateOrder = False
  OnCreate = DataModuleCreate
  OnDestroy = DataModuleDestroy
  Height = 446
  Width = 926
  object adoConn: TADOConnection
    ConnectionString = 
      'FILE NAME=C:\Program Files\Common Files\System\Ole DB\Data Links' +
      '\chis.udl'
    LoginPrompt = False
    Provider = 'SQLOLEDB.1'
    AfterConnect = adoConnAfterConnect
    Left = 28
    Top = 8
  end
  object adqSbInterface: TADOQuery
    Connection = adoConn
    Parameters = <>
    SQL.Strings = (
      'select * from mz_clinic_interface where deleted_flag = '#39'0'#39)
    Left = 296
    Top = 162
  end
  object adqChooseDept: TADOQuery
    Connection = adoConn
    CursorType = ctStatic
    Parameters = <
      item
        Name = 'dept_no'
        DataType = ftString
        Size = -1
        Value = Null
      end>
    SQL.Strings = (
      'declare @dept_no varchar(2),'
      #9#9'@RequestTime_begin varchar(20),'
      '        @RequestTime_end varchar(20)'
      ''
      '--set @dept_no = '#39'1'#39';'
      'set @dept_no = :dept_no'
      ''
      ''
      
        'select @RequestTime_begin=ini_value from ini_configure where ini' +
        '_keyname='#39'RequestTime_begin'#39';'
      
        'select @RequestTime_end=ini_value from ini_configure where ini_k' +
        'eyname='#39'RequestTime_end'#39';'
      ''
      ''
      'select * into #temp'
      '  from ('
      'select distinct a.request_date,'
      '       a.ampm,'
      '       a.unit_sn,'
      '       ltrim(rtrim(b.name)) unit_name,'
      '       ltrim(rtrim(isnull(c.item_code,'#39#39'))) group_sn,'
      '       ltrim(rtrim(isnull(c.item_name,'#39#39'))) group_name,'
      '       ltrim(rtrim(isnull(d.emp_sn,'#39#39'))) doctor_sn,'
      '       ltrim(rtrim(isnull(d.name,'#39#39'))) doctor_name,'
      '       min(b.address) address,'
      '       min(a.record_sn) record_sn,'
      '       min(a.clinic_type) clinic_type,'
      '       min(isnull(b.auto_gh_sort,999)) sort_flag,'
      '       min(isnull(b.virtual_flag,'#39'0'#39')) virtual_flag,'
      '       min(isnull(b.yy_flag,'#39'0'#39')) yy_flag'
      
        'from gh_request a (nolock),zd_unit_code b (nolock),mzfz_zd_item ' +
        'c(nolock),a_employee_mi d(nolock)'
      'where a.unit_sn = c.dept_code'
      '  and a.group_sn *= c.item_code'
      '  and a.doctor_sn *= d.emp_sn'
      '  and datediff(dd,a.request_date,getdate()) = 0'
      '  and a.open_flag = '#39'1'#39
      '  and a.unit_sn = b.unit_sn'
      '  and isnull(b.deleted_flag,'#39'0'#39') = '#39'0'#39
      '  and @dept_no = '#39'1'#39
      '  and a.clinic_type <= '#39'02'#39'   ------'#24179#35786#21495#12289#24613#35786#21495
      '  and a.current_no <= a.end_no  ------'#21495#26410#25346#28385
      
        'group by request_date,ampm,a.unit_sn,b.name,c.item_code,c.item_n' +
        'ame,d.emp_sn,d.name'
      ') rr'
      'where '
      '(rr.virtual_flag = '#39'0'#39') or'
      
        '(rr.virtual_flag = '#39'1'#39' and rr.yy_flag='#39'0'#39' and isnull(rr.doctor_s' +
        'n,'#39#39') <> '#39#39') or'
      
        '(rr.virtual_flag = '#39'1'#39' and rr.yy_flag='#39'1'#39' and isnull(rr.doctor_s' +
        'n,'#39#39') = '#39#39')'
      'order by ampm,sort_flag,unit_sn'
      ''
      ''
      ''
      'select * from #temp where unit_sn = '#39'c000003'#39
      'union all'
      'select * from #temp where unit_sn <> '#39'c000003'#39
      
        '   and getdate()>=CONVERT(varchar(10), getdate(), 120) +  '#39' '#39'+  ' +
        '@RequestTime_begin  '
      
        '   and getdate()<=CONVERT(varchar(10), getdate(), 120) +  '#39' '#39'+  ' +
        '@RequestTime_end  '
      'order by ampm,sort_flag,unit_sn'
      ''
      'drop table #temp;')
    Left = 293
    Top = 65
  end
  object adqGetSysdate: TADOQuery
    Connection = adoConn
    Parameters = <>
    SQL.Strings = (
      'select getdate() as sysdate')
    Left = 379
    Top = 345
  end
  object adqChooseDoctor: TADOQuery
    Connection = adoConn
    CursorType = ctStatic
    Parameters = <
      item
        Name = 'unit_sn'
        Attributes = [paNullable]
        DataType = ftString
        NumericScale = 255
        Precision = 255
        Size = 7
        Value = Null
      end
      item
        Name = 'ampm'
        Attributes = [paNullable]
        DataType = ftString
        NumericScale = 255
        Precision = 255
        Size = 1
        Value = Null
      end
      item
        Name = 'doctor_sn'
        Attributes = [paNullable]
        DataType = ftString
        NumericScale = 255
        Precision = 255
        Size = 7
        Value = Null
      end>
    SQL.Strings = (
      'select record_sn,request_date,ampm,a.unit_sn,'
      '       --group_sn,'
      '       ltrim(rtrim(b.name)) doctor_name,'
      '       ltrim(rtrim(c.name)) title_name,'
      '       a.doctor_sn'
      
        '       ,visit_count = (select count(*) count_pat from mz_visit_t' +
        'able (nolock)    ----'#21307#29983#20505#35786#20154#25968
      '          where visit_dept = a.unit_sn'
      '            and doctor_code = a.doctor_sn'
      '            and datediff(dd,visit_date,getdate()) = 0'
      '            and visit_flag = '#39'1'#39
      '            and max_order = 0'
      '            and ampm = a.ampm)'
      'from gh_request a (nolock),'
      '     a_employee_mi b (nolock),'
      '     zd_emp_title c (nolock)'
      'where datediff(dd,request_date,getdate()) = 0'
      '  and open_flag = '#39'1'#39
      '  and a.doctor_sn = b.emp_sn'
      '  and b.emp_tit_code *= c.code'
      '  and a.unit_sn <> '#39'3100400'#39
      '  and a.unit_sn = :unit_sn'
      '  and a.ampm = :ampm'
      '  and a.doctor_sn = :doctor_sn'
      '  --and a.group_sn is not null'
      '  and a.current_no <= a.end_no  ------'#21495#26410#25346#28385)
    Left = 288
    Top = 114
  end
  object adqGetPatientSn: TADOQuery
    Connection = adoConn
    Parameters = <>
    SQL.Strings = (
      'update gh_config set patient_sn = patient_sn + 1'
      'select patient_sn from gh_config')
    Left = 33
    Top = 220
  end
  object adqGetPatientMi: TADOQuery
    Connection = adoConn
    Parameters = <
      item
        Name = 'socialno'
        Attributes = [paNullable]
        DataType = ftString
        NumericScale = 255
        Precision = 255
        Size = 18
        Value = Null
      end
      item
        Name = 'zzrq'
        DataType = ftString
        Size = 10
        Value = Null
      end
      item
        Name = 'card_type'
        DataType = ftString
        Size = 10
        Value = Null
      end
      item
        Name = 'ifSelfPay'
        DataType = ftString
        Size = 50
        Value = Null
      end>
    SQL.Strings = (
      'declare'
      '  @socialno varchar(20),'
      '  @zzrq varchar(10),'
      '  @card_type varchar(10),'
      '  @ifSelfPay varchar(10)'
      ''
      'set @socialno = '#39'440623194305022639'#39
      'set @zzrq = '#39'20150630'#39
      'set @card_type = '#39'social'#39
      'set @ifSelfPay = '#39#33258#36153#39
      ''
      'set @socialno = :socialno'
      'set @zzrq = :zzrq'
      'set @card_type = :card_type'
      'set @ifSelfPay = :ifSelfPay'
      ''
      'if @card_type = '#39'social'#39
      'begin'
      '  select patient_id, name, max_times, home_tel, sex,'
      #9'isnull(lv_data,getdate()+300) lv_date,response_type,'
      #9#39'a'#39' source,outpatient_no,balance'
      '  from mz_patient_mi (nolock)'
      '  where social_no = @socialno '
      'union all '
      '  select patient_id, name, max_times, home_tel, sex,'
      #9'isnull(lv_data,getdate()+300) lv_date,response_type,'
      #9#39'b'#39' source,outpatient_no,balance'
      '  from mz_patient_mi_b (nolock)'
      '  where social_no = @socialno '
      '  order by max_times desc'
      'end'
      ''
      'else if @card_type = '#39'barcode'#39
      ''
      'begin'
      '  select patient_id, name, max_times, home_tel, sex,'
      #9'isnull(lv_data,getdate()+300) lv_date,response_type,'
      #9#39'a'#39' source,outpatient_no,balance'
      '  from mz_patient_mi (nolock)'
      '  where p_bar_code = @socialno '
      'union all '
      '  select patient_id, name, max_times, home_tel, sex,'
      #9'isnull(lv_data,getdate()+300) lv_date,response_type,'
      #9#39'b'#39' source,outpatient_no,balance'
      '  from mz_patient_mi_b (nolock)'
      '  where p_bar_code = @socialno '
      '  order by max_times desc'
      'end'
      ''
      ''
      ''
      ''
      ''
      ''
      ''
      ''
      '--if @ifSelfPay='#39#33258#36153#39
      '--begin--if @ifSelfPay='#39#33258#36153#39
      '--'
      '--'#9'-- 2014.08.08 '#36890#36807#36523#20221#35777#25346#21495
      '--'#9'if @card_type = '#39'social'#39
      '--'#9'begin'
      '--'#9'  select top 5'
      '--'#9#9'patient_id, name, max_times, home_tel, sex,'
      '--'#9#9'isnull(lv_data,getdate()+300) lv_date,'
      '--'#9#9#39'a'#39' source'
      '--'#9'  into #pp'
      '--'#9'  from mz_patient_mi (nolock)'
      '--'#9'  where'
      '--'#9#9'social_no = @socialno and'
      '--'#9#9'response_type='#39'01'#39
      '--'#9'  order by lv_date desc'
      '--'
      '--'#9'  if @@rowcount = 0'
      '--'#9'  begin'
      '--'#9#9'insert into #pp'
      '--'#9#9'select top 5'
      '--'#9#9'  patient_id, name, max_times, home_tel, sex,'
      '--'#9#9'  isnull(lv_data,getdate()+300) lv_date,'
      '--'#9#9'  '#39'b'#39' source'
      '--'#9#9'from mz_patient_mi_b (nolock)'
      '--'#9#9'where'
      '--'#9#9'  social_no = @socialno and'
      '--'#9#9'  response_type='#39'01'#39
      '--'#9#9'order by lv_date desc'
      '--'#9'  end'
      '--'
      '--'#9'  select * from #pp order by lv_date desc'
      '--'
      '--'#9'  drop table #pp'
      '--'#9'end'
      '--'#9'-- 2014.08.08 '#36890#36807#26465#24418#30721#25346#21495
      '--'#9'else if @card_type = '#39'barcode'#39
      '--'#9'begin'
      '--'#9'  select patient_id, name, max_times, home_tel, sex,'
      '--'#9#9'isnull(lv_data,getdate()+300) lv_date,'
      '--'#9#9#39'a'#39' source'
      '--'#9'  from'
      '--'#9#9'view_mz_patient_mi (nolock)'
      '--'#9'  where'
      '--'#9#9'p_bar_code = @socialno'
      '--'#9#9'and response_type='#39'01'#39
      '--'#9'  order by lv_date desc'
      '--'#9'end'
      '--'
      '--end --/if @ifSelfPay='#39#33258#36153#39
      '--else'
      '--begin'
      '--'
      '---- 2014.08.08 '#36890#36807#36523#20221#35777#25346#21495
      '--if @card_type = '#39'social'#39
      '--begin'
      '--  select top 5'
      '--    patient_id, name, max_times, home_tel, sex,'
      '--    isnull(lv_data,getdate()+300) lv_date,'
      '--    '#39'a'#39' source'
      '--  into #pp2'
      '--  from mz_patient_mi (nolock)'
      '--  where'
      '--    social_no = @socialno '
      '----    and'
      '----    ('
      '----      len(outpatient_no) > 2 or         -- '#22522#26412#21512#20316#21307#30103
      '----      balance = '#39'1'#39' or                  -- '#32844#24037#38376#35786
      '----      '#39'1899-01-01'#39' = @zzrq              -- '#33258#36153
      '----    )'
      '--  order by lv_date desc'
      '--'
      '--  if @@rowcount = 0'
      '--  begin'
      '--    insert into #pp2'
      '--    select top 5'
      '--      patient_id, name, max_times, home_tel, sex,'
      '--      isnull(lv_data,getdate()+300) lv_date,'
      '--      '#39'b'#39' source'
      '--    from mz_patient_mi_b (nolock)'
      '--    where'
      '--      social_no = @socialno '
      '----     and'
      '----      ('
      '----        len(outpatient_no) > 2 or      -- '#22522#26412#21512#20316#21307#30103
      '----        balance = '#39'1'#39' or               -- '#32844#24037#38376#35786
      '----        '#39'1899-01-01'#39' = @zzrq           -- '#33258#36153
      '----      )'
      '--    order by lv_date desc'
      '--  end'
      '--'
      '--  select * from #pp2 order by lv_date desc'
      '--'
      '--  drop table #pp2'
      '--end'
      '---- 2014.08.08 '#36890#36807#26465#24418#30721#25346#21495
      '--else if @card_type = '#39'barcode'#39
      '--begin'
      '--  select patient_id, name, max_times, home_tel, sex,   '
      '--    isnull(lv_data,getdate()+300) lv_date,'
      '--    '#39'a'#39' source'
      '--  from'
      '--    view_mz_patient_mi (nolock)'
      '--  where'
      '--    p_bar_code = @socialno'
      '--  order by lv_date desc'
      '--end'
      '--'
      '--end'
      '')
    Left = 300
    Top = 207
  end
  object adqSql: TADOQuery
    Connection = adoConn
    Parameters = <>
    Left = 293
    Top = 17
  end
  object adqTransPMI: TADOQuery
    Connection = adoConn
    Parameters = <
      item
        Name = 'pid'
        Size = -1
        Value = Null
      end>
    SQL.Strings = (
      'declare @pid char(12)'
      ''
      'set @pid = :pid'
      ''
      'insert into mz_patient_mi'
      'select * from mz_patient_mi_b '
      'where patient_id = @pid'
      ''
      'delete from mz_patient_mi_b '
      'where patient_id = @pid')
    Left = 154
    Top = 8
  end
  object adqVisitTable: TADOQuery
    Connection = adoConn
    Parameters = <
      item
        Name = 'pid'
        DataType = ftString
        NumericScale = 255
        Precision = 255
        Size = 12
        Value = Null
      end
      item
        Name = 'vs_date'
        Attributes = [paSigned]
        DataType = ftInteger
        Precision = 10
        Size = 4
        Value = Null
      end>
    SQL.Strings = (
      'select * from mz_visit_table'
      'where patient_id = :pid'
      '  and datediff(dd,visit_date,:vs_date) = 0'
      '  and isnull(visit_flag,'#39#39') <> '#39'9'#39)
    Left = 37
    Top = 313
  end
  object cdsVisitTable: TClientDataSet
    Aggregates = <>
    Params = <
      item
        DataType = ftString
        Precision = 255
        NumericScale = 255
        Name = 'pid'
        ParamType = ptInput
        Size = 12
      end
      item
        DataType = ftInteger
        Precision = 10
        Name = 'vs_date'
        ParamType = ptInput
        Size = 4
      end>
    ProviderName = 'dspVisitTable'
    OnReconcileError = cdsPatientMiReconcileError
    Left = 179
    Top = 312
  end
  object dspVisitTable: TDataSetProvider
    DataSet = adqVisitTable
    Left = 109
    Top = 313
  end
  object adqGhRequest: TADOQuery
    Connection = adoConn
    Parameters = <
      item
        Name = 'sn'
        Attributes = [paSigned]
        DataType = ftInteger
        Precision = 10
        Size = 4
        Value = Null
      end>
    SQL.Strings = (
      'declare @sn int'
      ''
      'set @sn = :sn'
      ''
      'select current_no from gh_request'
      'where record_sn = @sn'
      ''
      'update gh_request set current_no = current_no + 1'
      'where record_sn = @sn'
      '')
    Left = 105
    Top = 170
  end
  object adqPatientMi: TADOQuery
    Connection = adoConn
    Parameters = <
      item
        Name = 'pid'
        DataType = ftString
        NumericScale = 255
        Precision = 255
        Size = 12
        Value = Null
      end>
    SQL.Strings = (
      'select * from mz_patient_mi'
      'where patient_id = :pid')
    Left = 297
    Top = 300
  end
  object dspPatientMi: TDataSetProvider
    DataSet = adqPatientMi
    Left = 368
    Top = 299
  end
  object cdsPatientMi: TClientDataSet
    Aggregates = <>
    Params = <
      item
        DataType = ftString
        Precision = 255
        NumericScale = 255
        Name = 'pid'
        ParamType = ptInput
        Size = 12
      end>
    ProviderName = 'dspPatientMi'
    OnReconcileError = cdsPatientMiReconcileError
    Left = 433
    Top = 299
  end
  object adqGhRecord: TADOQuery
    Connection = adoConn
    CursorType = ctStatic
    Parameters = <
      item
        Name = 'socialno'
        DataType = ftString
        Size = 1
        Value = '%'
      end>
    SQL.Strings = (
      'select a.patient_id,a.times,a.gh_dept,a.doctor_code,'
      '       a.visit_flag, a.name p_name,'
      '       c.name dept_name,d.name doctor_name,'
      
        '       cf_count = (select count(*) from mz_detail_charge (nolock' +
        ') where patient_id = a.patient_id and times = a.times)'
      'from mz_visit_table a (nolock),'
      '     mz_patient_mi b (nolock),'
      '     zd_unit_code c (nolock),'
      '     a_employee_mi d (nolock)'
      'where a.patient_id = b.patient_id'
      '  and a.clinic_type = '#39'A1'#39
      '  and isnull(a.visit_flag,'#39#39') <> '#39'9'#39
      '  and a.gh_dept = c.unit_sn'
      '  and a.doctor_code *= d.emp_sn'
      '  and b.social_no = :socialno'
      '  and datediff(dd,visit_date,getdate()) = 0')
    Left = 33
    Top = 171
  end
  object adqWebGhDetl: TADOQuery
    Connection = adoConn
    Parameters = <
      item
        Name = 'socialno'
        Attributes = [paNullable]
        DataType = ftString
        NumericScale = 255
        Precision = 255
        Size = 20
        Value = Null
      end>
    SQL.Strings = (
      'select * from web_gh_detl_wsj (nolock)'
      'where datediff(dd,watch_starttime,getdate()) = 0'
      '  and patient_identity = :socialno')
    Left = 32
    Top = 115
  end
  object adqMzfz: TADOQuery
    Connection = adoConn
    Parameters = <>
    SQL.Strings = (
      'select * from mzfz_patient_order'
      'where 1 = 2')
    Left = 36
    Top = 269
  end
  object dspMzfz: TDataSetProvider
    DataSet = adqMzfz
    Left = 88
    Top = 269
  end
  object cdsMzfz: TClientDataSet
    Aggregates = <>
    Params = <>
    ProviderName = 'dspMzfz'
    OnReconcileError = cdsPatientMiReconcileError
    Left = 146
    Top = 269
  end
  object adqMzfzGhConfig: TADOQuery
    Connection = adoConn
    Parameters = <>
    SQL.Strings = (
      'update gh_config set daily_gh_sn = daily_gh_sn + 1 '
      'select daily_gh_sn from gh_config')
    Left = 189
    Top = 171
  end
  object adqGhReceiptSn: TADOQuery
    Connection = adoConn
    Parameters = <>
    SQL.Strings = (
      'update mz_order_generator set max_sn = max_sn + 1'
      'where define = '#39'gh_receipt_sn'#39
      ''
      'select max_sn from mz_order_generator '
      'where define = '#39'gh_receipt_sn'#39)
    Left = 117
    Top = 219
  end
  object adqDoctorCount: TADOQuery
    Connection = adoConn
    Parameters = <
      item
        Name = 'dept'
        Attributes = [paNullable]
        DataType = ftString
        NumericScale = 255
        Precision = 255
        Size = 7
        Value = Null
      end
      item
        Name = 'doctor'
        Attributes = [paNullable]
        DataType = ftString
        NumericScale = 255
        Precision = 255
        Size = 5
        Value = Null
      end
      item
        Name = 'ampm'
        Attributes = [paNullable]
        DataType = ftString
        NumericScale = 255
        Precision = 255
        Size = 1
        Value = Null
      end>
    SQL.Strings = (
      'exec mzfz_doctor_visit_count :dept, :doctor, :ampm')
    Left = 118
    Top = 113
  end
  object adoZyConn: TADOConnection
    LoginPrompt = False
    Provider = 'SQLOLEDB.1'
    AfterConnect = adoZyConnAfterConnect
    Left = 298
    Top = 392
  end
  object adqDoctorDaily: TADOQuery
    Connection = adoZyConn
    CursorType = ctStatic
    Parameters = <
      item
        Name = 'dept'
        DataType = ftString
        NumericScale = 255
        Precision = 255
        Size = 10
        Value = Null
      end>
    SQL.Strings = (
      
        'select a.op_dept,a.emp_code,rtrim(a.emp_name) emp_name,b.name wo' +
        'rk_name '
      'from rs_worklist a (nolock), rs_zd_work_public b (nolock)'
      'where a.work_code = b.work_id'
      '  and isnull(b.if_rest,'#39'0'#39') = '#39'0'#39'   ----'#19978#29677#26631#24535
      '  and a.group_code in( '#39'1'#39','#39'2'#39')   ----= '#39'1'#39'            ----'#38376#35786#21307#29983
      '  and datediff(dd,a.work_date ,getdate()) = 0'
      '  and export_flag = '#39'1'#39
      '  and a.op_dept = :dept'
      'order by op_dept,emp_name')
    Left = 110
    Top = 375
  end
  object adqMzDirty: TADOQuery
    Connection = adoConn
    Parameters = <>
    SQL.Strings = (
      'set transaction isolation level read uncommitted')
    Left = 93
    Top = 7
  end
  object adqZyDirty: TADOQuery
    Connection = adoZyConn
    Parameters = <>
    SQL.Strings = (
      'set transaction isolation level read uncommitted')
    Left = 366
    Top = 392
  end
  object adqChooseDeptZk: TADOQuery
    Connection = adoConn
    CursorType = ctStatic
    Parameters = <
      item
        Name = 'ampm'
        DataType = ftString
        Size = 1
        Value = 'a'
      end>
    SQL.Strings = (
      '-----'#25945#25480#38376#35786#21333#29420#22788#29702#65292#25353#36873#25321#21307#29983#27169#24335
      'select distinct request_date,ampm,a.unit_sn,'
      '       ltrim(rtrim(b.name)) unit_name,'
      '       min(b.address) address,'
      '       min(record_sn) record_sn,'
      '       min(clinic_type) clinic_type'
      
        '       ,visit_count = (select count(*) count_pat from mz_visit_t' +
        'able (nolock)    ------'#31185#23460#20505#35786#20154#25968
      '          where visit_dept = a.unit_sn'
      '            and datediff(dd,visit_date,getdate()) = 0'
      '            and visit_flag = '#39'1'#39
      '            and max_order = 0'
      '            and ampm = a.ampm)'
      'from gh_request a (nolock),zd_unit_code b (nolock)'
      'where datediff(dd,request_date,getdate()) = 0'
      '  and open_flag = '#39'1'#39
      '  and a.unit_sn = b.unit_sn'
      '  and isnull(b.deleted_flag,'#39'0'#39') = '#39'0'#39
      '  and clinic_type <= '#39'02'#39'  ------'#24179#35786#21495#12289#24613#35786#21495
      '  and (a.unit_sn > '#39'1021900'#39' and a.unit_sn < '#39'1021999'#39')'
      '  and a.ampm = :ampm'
      '  and a.current_no <= a.end_no ------'#21495#26410#25346#28385
      'group by request_date,ampm,a.unit_sn,b.name')
    Left = 200
    Top = 65
  end
  object adqDeptZkDaily: TADOQuery
    Connection = adoConn
    CursorType = ctStatic
    Parameters = <>
    SQL.Strings = (
      '-----'#25945#25480#38376#35786#21333#29420#22788#29702#65292#25353#36873#25321#21307#29983#27169#24335
      'select distinct --request_date,'
      '       a.unit_sn,'
      '       ltrim(rtrim(b.name)) unit_name,'
      '       min(b.address) address,'
      '--       min(record_sn) record_sn,'
      '--       min(clinic_type) clinic_type,'
      '--       min(ampm) ampm,'
      
        '       case when count(*) > 1 then '#39#20840#22825#39' when min(ampm) = '#39'a'#39' the' +
        'n '#39#19978#21320#39' else '#39#19979#21320#39' end ampm'
      'from gh_request a (nolock),zd_unit_code b (nolock)'
      'where datediff(dd,request_date,getdate()) = 0'
      '  and open_flag = '#39'1'#39
      '  and a.unit_sn = b.unit_sn'
      '  and isnull(b.deleted_flag,'#39'0'#39') = '#39'0'#39
      '  and clinic_type <= '#39'02'#39'  ------'#24179#35786#21495#12289#24613#35786#21495
      '  and (a.unit_sn > '#39'1021900'#39' and a.unit_sn < '#39'1021999'#39')'
      'group by a.unit_sn,b.name')
    Left = 34
    Top = 375
  end
  object adqAddPatientID: TADOQuery
    Connection = adoConn
    Parameters = <>
    Left = 389
    Top = 205
  end
  object adqGetDateTime: TADOQuery
    Connection = adoConn
    Parameters = <>
    SQL.Strings = (
      'select getdate()')
    Left = 296
    Top = 344
  end
  object adqGetPatientMiBySF: TADOQuery
    Connection = adoConn
    Parameters = <>
    Left = 408
    Top = 254
  end
  object cdsResponseXml_InsertReg: TClientDataSet
    Aggregates = <>
    Params = <>
    Left = 600
    Top = 8
    object cdsResponseXml_InsertRegHisRegId: TStringField
      FieldName = 'HisRegId'
      Size = 50
    end
    object cdsResponseXml_InsertRegRegisterNo: TStringField
      FieldName = 'RegisterNo'
      Size = 10
    end
    object cdsResponseXml_InsertRegCardNO: TStringField
      FieldName = 'CardNO'
      Size = 30
    end
    object cdsResponseXml_InsertRegIdNoNO: TStringField
      FieldName = 'IdNoNO'
      Size = 30
    end
    object cdsResponseXml_InsertRegCardType: TStringField
      FieldName = 'CardType'
      Size = 10
    end
    object cdsResponseXml_InsertRegOrderNO: TIntegerField
      FieldName = 'OrderNO'
    end
    object cdsResponseXml_InsertRegFlowNO: TStringField
      FieldName = 'FlowNO'
    end
    object cdsResponseXml_InsertRegDeptNm: TStringField
      FieldName = 'DeptNm'
    end
    object cdsResponseXml_InsertRegDeptSpace: TStringField
      FieldName = 'DeptSpace'
    end
    object cdsResponseXml_InsertRegDocName: TStringField
      FieldName = 'DocName'
    end
    object cdsResponseXml_InsertRegVisitType: TStringField
      FieldName = 'VisitType'
      Size = 10
    end
    object cdsResponseXml_InsertRegPatientName: TStringField
      FieldName = 'PatientName'
    end
    object cdsResponseXml_InsertRegSex: TStringField
      FieldName = 'Sex'
      Size = 10
    end
    object cdsResponseXml_InsertRegAge: TIntegerField
      FieldName = 'Age'
    end
    object cdsResponseXml_InsertRegSIType: TStringField
      FieldName = 'SIType'
      Size = 30
    end
    object cdsResponseXml_InsertRegRegTime: TDateTimeField
      FieldName = 'RegTime'
    end
  end
  object adqGetPatientMiByBar: TADOQuery
    Connection = adoConn
    Parameters = <
      item
        Name = 'bar_code'
        DataType = ftString
        Size = 20
        Value = Null
      end
      item
        Name = 'pid'
        DataType = ftString
        Size = 12
        Value = Null
      end>
    SQL.Strings = (
      'select social_no'
      'from'
      '  view_mz_patient_mi'
      'where'
      '  ((p_bar_code = :bar_code) or (patient_id = :pid)) and'
      '  social_no is not null and'
      '  ltrim(rtrim(social_no)) <> '#39#39' and'
      '  len(social_no) >= 18'
      'group by social_no')
    Left = 296
    Top = 254
  end
  object dspDept: TDataSetProvider
    DataSet = adqChooseDept
    Left = 364
    Top = 64
  end
  object cdsDept: TClientDataSet
    Aggregates = <>
    Params = <
      item
        DataType = ftUnknown
        Name = 'dept_no'
        ParamType = ptInput
        Size = -1
      end>
    ProviderName = 'dspDept'
    Left = 422
    Top = 63
  end
  object dspSql: TDataSetProvider
    DataSet = adqSql
    Options = [poAllowCommandText, poUseQuoteChar]
    Left = 360
    Top = 16
  end
  object cdsSql: TClientDataSet
    Aggregates = <>
    Params = <>
    ProviderName = 'dspSql'
    Left = 424
    Top = 16
  end
  object cdsSbInterface: TClientDataSet
    Aggregates = <>
    Params = <>
    ProviderName = 'dspSbInterface'
    Left = 464
    Top = 160
  end
  object dspSbInterface: TDataSetProvider
    DataSet = adqSbInterface
    Left = 384
    Top = 160
  end
  object cdsResponseXml_PatMsg: TClientDataSet
    Aggregates = <>
    Params = <>
    Left = 704
    Top = 56
    object cdsResponseXml_PatMsgHosPatId: TStringField
      FieldName = 'HosPatId'
    end
    object cdsResponseXml_PatMsgName: TStringField
      FieldName = 'Name'
    end
    object cdsResponseXml_PatMsgSex: TStringField
      FieldName = 'Sex'
      Size = 2
    end
    object cdsResponseXml_PatMsgBirthDay: TStringField
      FieldName = 'BirthDay'
    end
    object cdsResponseXml_PatMsgIdentityNo: TStringField
      FieldName = 'IdentityNo'
    end
    object cdsResponseXml_PatMsgFamilyAddress: TStringField
      FieldName = 'FamilyAddress'
      Size = 100
    end
    object cdsResponseXml_PatMsgPhone: TStringField
      FieldName = 'Phone'
    end
    object cdsResponseXml_PatMsgFamilyPhone: TStringField
      FieldName = 'FamilyPhone'
    end
    object cdsResponseXml_PatMsgCardNo: TStringField
      FieldName = 'CardNo'
    end
    object cdsResponseXml_PatMsgCardType: TStringField
      FieldName = 'CardType'
    end
    object cdsResponseXml_PatMsgPatType: TStringField
      FieldName = 'PatType'
      Size = 50
    end
    object cdsResponseXml_PatMsgPatMoney: TFloatField
      FieldName = 'PatMoney'
    end
  end
  object adqGetPatMsg: TADOQuery
    Connection = adoConn
    Parameters = <
      item
        Name = 'id'
        DataType = ftString
        Size = 18
        Value = '%'
      end
      item
        Name = 'bar_code'
        DataType = ftString
        Size = 20
        Value = '%'
      end
      item
        Name = 'pid'
        DataType = ftString
        Size = 12
        Value = '%'
      end>
    SQL.Strings = (
      'select'
      
        '  a.patient_id HosPatId,a.name Name,b.name Sex,convert(varchar(1' +
        '0),birthday,121) BirthDay,'
      
        '  social_no IdentityNo,home_street FamilyAddress,home_tel Phone,' +
        'home_tel FamilyPhone,'
      
        '  social_no CardNo,'#39#36523#20221#35777#39' CardType,c.code,c.name PatType,0.0 PatM' +
        'oney'
      'from view_mz_patient_mi a,zd_sex_code b,zd_responce_type c'
      'where a.sex = b.code and'
      'a.response_type = c.code and'
      'a.social_no = :id'
      ''
      'union'
      ''
      'select'
      
        '  a.patient_id HosPatId,a.name Name,b.name Sex,convert(varchar(1' +
        '0),birthday,121) BirthDay,'
      
        '  social_no IdentityNo,home_street FamilyAddress,home_tel Phone,' +
        'home_tel FamilyPhone,'
      
        '  p_bar_code CardNo,'#39#30149#21382#26465#24418#30721#39' CardType,c.code,c.name PatType,0.0 P' +
        'atMoney'
      'from view_mz_patient_mi a,zd_sex_code b,zd_responce_type c'
      'where a.sex = b.code and'
      'a.response_type = c.code and'
      'a.p_bar_code = :bar_code'
      ''
      'union'
      ''
      'select'
      
        '  a.patient_id HosPatId,a.name Name,b.name Sex,convert(varchar(1' +
        '0),birthday,121) BirthDay,'
      
        '  social_no IdentityNo,home_street FamilyAddress,home_tel Phone,' +
        'home_tel FamilyPhone,'
      
        '  a.patient_id CardNo,'#39#22788#26041#26465#24418#30721#39' CardType,c.code,c.name PatType,0.0' +
        ' PatMoney'
      'from view_mz_patient_mi a,zd_sex_code b,zd_responce_type c'
      'where a.sex = b.code and'
      'a.response_type = c.code and'
      'a.patient_id = :pid'
      ''
      'order by c.code desc')
    Left = 600
    Top = 56
  end
  object cdsResponseXml_PatDoc: TClientDataSet
    Aggregates = <>
    Params = <>
    Left = 760
    Top = 112
    object cdsResponseXml_PatDocFlowNo: TStringField
      FieldName = 'FlowNo'
    end
    object cdsResponseXml_PatDocPatId: TStringField
      FieldName = 'PatId'
    end
    object cdsResponseXml_PatDocPatName: TStringField
      FieldName = 'PatName'
    end
    object cdsResponseXml_PatDocConsultationTimes: TDateTimeField
      FieldName = 'ConsultationTimes'
    end
    object cdsResponseXml_PatDocAccount: TStringField
      FieldName = 'Account'
    end
    object cdsResponseXml_PatDocStaffId: TStringField
      FieldName = 'StaffId'
    end
    object cdsResponseXml_PatDocStaffName: TStringField
      FieldName = 'StaffName'
    end
    object cdsResponseXml_PatDocStaffType: TStringField
      FieldName = 'StaffType'
    end
    object cdsResponseXml_PatDocDeptId: TStringField
      FieldName = 'DeptId'
    end
    object cdsResponseXml_PatDocDeptName: TStringField
      FieldName = 'DeptName'
    end
    object cdsResponseXml_PatDocAccountType: TStringField
      FieldName = 'AccountType'
    end
    object cdsResponseXml_PatDocCard: TStringField
      FieldName = 'Card'
    end
    object cdsResponseXml_PatDocAddress: TStringField
      FieldName = 'Address'
      Size = 100
    end
    object cdsResponseXml_PatDocAge: TStringField
      FieldName = 'Age'
    end
    object cdsResponseXml_PatDocAllergy: TStringField
      FieldName = 'Allergy'
      Size = 100
    end
    object cdsResponseXml_PatDocPhone: TStringField
      FieldName = 'Phone'
    end
    object cdsResponseXml_PatDocSex: TStringField
      FieldName = 'Sex'
      Size = 2
    end
  end
  object adqOutPatDoc: TADOQuery
    Connection = adoConn
    Parameters = <
      item
        Name = 'bar_code'
        DataType = ftString
        Size = 20
        Value = '%'
      end
      item
        Name = 'id'
        DataType = ftString
        Size = 18
        Value = '%'
      end>
    SQL.Strings = (
      'select'
      
        '  a.times FlowNo,a.visit_date ConsultationTimes,a.patient_id Pat' +
        'Id,a.name PatName,'
      
        '  case when isnull(b.p_bar_code,'#39#39') <> '#39#39' then b.p_bar_code when' +
        ' isnull(b.social_no,'#39#39') <> '#39#39' then b.social_no end Account,'
      
        '  isnull(a.doctor_code,'#39#39') StaffId,isnull(d.name,'#39#39') StaffName,'#39 +
        #21307#29983#39' StaffType,a.visit_dept DeptId,'
      
        '  c.name DeptName,'#39#38376#35786#21495#39' AccountType,isnull(b.home_street,'#39#39') Add' +
        'ress,'
      
        '  age Age,'#39#39' Allergy,isnull(home_tel,'#39#39') Phone,case b.sex when '#39 +
        '1'#39' then '#39#30007#39' when '#39'2'#39' then '#39#22899#39' end Sex'
      
        'from view_mz_visit_table a,view_mz_patient_mi b,zd_unit_code c,a' +
        '_employee_mi d,'
      
        '    (select patient_id,max(times) max_time from view_mz_visit_ta' +
        'ble group by patient_id) e'
      'where a.patient_id = b.patient_id and'
      'a.visit_dept *= c.unit_sn and'
      'a.doctor_code *= d.emp_sn and'
      'a.patient_id = e.patient_id and'
      'a.times = e.max_time and'
      '(b.p_bar_code = :bar_code or b.social_no = :id)'
      'order by a.visit_date desc,a.patient_id')
    Left = 592
    Top = 112
  end
  object adqInPatDoc: TADOQuery
    Connection = adoConn
    Parameters = <
      item
        Name = 'bar_code'
        DataType = ftString
        Size = 12
        Value = '%'
      end
      item
        Name = 'id'
        DataType = ftString
        Size = 18
        Value = '%'
      end>
    SQL.Strings = (
      'select'
      
        '  a.admiss_times FlowNo,a.admiss_date ConsultationTimes,a.patien' +
        't_id PatId,a.name PatName,'
      
        '  a.inpatient_no Account, a.admiss_physician StaffId,d.name Staf' +
        'fName,'#39#20303#38498#21307#29983#39' StaffType,a.dept DeptId,'
      
        '  c.dept_name DeptName,'#39#20303#38498#21495#39' AccountType,isnull(b.social_no,'#39#39') ' +
        'Card,isnull(b.home_street,'#39#39') Address,'
      
        '  datediff(year,a.birth_date,getdate()) Age,'#39#39' Allergy,isnull(ho' +
        'me_tel,'#39#39') Phone,'
      '  case b.sex when '#39'1'#39' then '#39#30007#39' when '#39'2'#39' then '#39#22899#39' end Sex'
      
        'from view_zy_allpatient a,a_patient_mi b,zy_adtward c,a_employee' +
        '_mi d,'
      
        '    (select patient_id,max(admiss_times) max_time from view_zy_a' +
        'llpatient group by patient_id) e'
      'where a.patient_id = b.patient_id and'
      'a.dept *= c.dept_sn and'
      'a.ward *= c.ward_sn and'
      'a.admiss_physician *= d.emp_sn and'
      'a.patient_id = e.patient_id and'
      'a.admiss_times = e.max_time and'
      '(a.inpatient_no = :bar_code or b.social_no = :id)'
      'order by a.admiss_date desc,a.patient_id')
    Left = 664
    Top = 112
  end
  object cdsResponseXml_IDCardCheck: TClientDataSet
    Aggregates = <>
    Params = <>
    Left = 712
    Top = 160
    object cdsResponseXml_IDCardCheckResultMark: TStringField
      FieldName = 'ResultMark'
      Size = 1
    end
    object cdsResponseXml_IDCardCheckPatientId: TStringField
      FieldName = 'PatientId'
      FixedChar = True
      Size = 12
    end
    object cdsResponseXml_IDCardCheckPatientName: TStringField
      FieldName = 'PatientName'
      Size = 32
    end
    object cdsResponseXml_IDCardCheckSex: TStringField
      FieldName = 'Sex'
      Size = 8
    end
    object cdsResponseXml_IDCardCheckBirthday: TStringField
      FieldName = 'Birthday'
      Size = 10
    end
    object cdsResponseXml_IDCardCheckMobile: TStringField
      FieldName = 'Mobile'
      Size = 16
    end
    object cdsResponseXml_IDCardCheckCardNo: TStringField
      FieldName = 'CardNo'
    end
    object cdsResponseXml_IDCardCheckCardType: TStringField
      FieldName = 'CardType'
      Size = 6
    end
    object cdsResponseXml_IDCardCheckPactID: TStringField
      FieldName = 'PactID'
      FixedChar = True
      Size = 2
    end
    object cdsResponseXml_IDCardCheckPactName: TStringField
      FieldName = 'PactName'
      Size = 32
    end
  end
  object adqIDCardCheck: TADOQuery
    Connection = adoConn
    CursorType = ctStatic
    Parameters = <
      item
        Name = 'id'
        DataType = ftString
        Size = 18
        Value = '%'
      end
      item
        Name = 'bar_code'
        DataType = ftString
        Size = 20
        Value = '%'
      end>
    SQL.Strings = (
      'select'
      
        '  a.patient_id PatientId,a.name PatientName,b.name Sex,convert(v' +
        'archar(10),birthday,121) Birthday,'
      
        '  home_tel Mobile,social_no CardNo,'#39#36523#20221#35777#39' CardType,c.code PactID,' +
        'c.name PactName'
      'from view_mz_patient_mi a,zd_sex_code b,zd_responce_type c'
      'where a.sex = b.code and'
      'a.response_type = c.code and'
      'a.social_no = :id'
      ''
      'union'
      ''
      'select'
      
        '  a.patient_id PatientId,a.name PatientName,b.name Sex,convert(v' +
        'archar(10),birthday,121) Birthday,'
      
        '  home_tel Mobile,p_bar_code CardNo,'#39#26465#24418#30721#39' CardType,c.code PactID' +
        ',c.name PactName'
      'from view_mz_patient_mi a,zd_sex_code b,zd_responce_type c'
      'where a.sex = b.code and'
      'a.response_type = c.code and'
      'a.p_bar_code = :bar_code'
      ''
      'order by c.code desc')
    Left = 592
    Top = 160
  end
  object adqCreateCardPatInfo: TADOQuery
    Connection = adoConn
    CursorType = ctStatic
    Parameters = <>
    SQL.Strings = (
      'select * from mz_patient_mi where 1 = 2')
    Left = 592
    Top = 208
  end
  object cdsDoctor: TClientDataSet
    Aggregates = <>
    IndexFieldNames = 'visit_count'
    Params = <
      item
        DataType = ftString
        Precision = 255
        NumericScale = 255
        Name = 'unit_sn'
        ParamType = ptInput
        Size = 7
      end
      item
        DataType = ftString
        Precision = 255
        NumericScale = 255
        Name = 'ampm'
        ParamType = ptInput
        Size = 1
      end
      item
        DataType = ftString
        Precision = 255
        NumericScale = 255
        Name = 'doctor_sn'
        ParamType = ptInput
        Size = 7
      end>
    ProviderName = 'dspDoctor'
    Left = 436
    Top = 112
  end
  object dspDoctor: TDataSetProvider
    DataSet = adqChooseDoctor
    Left = 373
    Top = 111
  end
  object adqGetRegList: TADOQuery
    Connection = adoConn
    CursorType = ctStatic
    Parameters = <
      item
        Name = 'id'
        Attributes = [paNullable]
        DataType = ftString
        NumericScale = 255
        Precision = 255
        Size = 18
        Value = '%'
      end
      item
        Name = 'bar_code'
        Attributes = [paNullable]
        DataType = ftString
        NumericScale = 255
        Precision = 255
        Size = 20
        Value = '%'
      end
      item
        Name = 'pid'
        DataType = ftString
        NumericScale = 255
        Precision = 255
        Size = 12
        Value = '%'
      end>
    SQL.Strings = (
      ''
      
        'select a.visit_date RegisterDate,a.times VisitNO,a.patient_id+'#39'#' +
        #39'+convert(varchar(10),a.times) VisitID,case when visit_flag='#39'1'#39' ' +
        'then '#39'N'#39' else '#39'Y'#39'  end IsDiagnoses,'
      
        '       a.name PatName,c.name DepName,0 SumFee,b.name DoctName,ca' +
        'se when a.ampm='#39'a'#39' then  '#39#19978#21320#29677#39' else '#39#19979#21320#29677#39' end  ShiftName '
      
        '  from mz_visit_table a,a_employee_mi b,zd_unit_code c,view_mz_p' +
        'atient_mi d'
      ' where a.gh_doctor *=  b.emp_sn'
      '   and a.gh_dept = c.unit_sn'
      '   and a.patient_id = d.patient_id'
      '   and a.visit_flag in ('#39'1'#39')'
      '   and a.clinic_type = '#39'A1'#39
      '   and datediff(day,a.visit_date,getdate())=0'
      '   and d.social_no = :id'
      ''
      'union'
      ''
      
        'select a.visit_date RegisterDate,a.times VisitNO,a.patient_id+'#39'#' +
        #39'+convert(varchar(10),a.times)  VisitID,case when visit_flag='#39'1'#39 +
        ' then '#39'N'#39' else '#39'Y'#39'  end IsDiagnoses,'
      
        '       a.name PatName,c.name DepName,0 SumFee,b.name DoctName,ca' +
        'se when a.ampm='#39'a'#39' then  '#39#19978#21320#29677#39' else '#39#19979#21320#29677#39' end  ShiftName '
      
        '  from mz_visit_table a,a_employee_mi b,zd_unit_code c,view_mz_p' +
        'atient_mi d'
      ' where a.gh_doctor *=  b.emp_sn'
      '   and a.gh_dept = c.unit_sn'
      '   and a.patient_id = d.patient_id'
      '   and a.visit_flag in ('#39'1'#39')'
      '   and a.clinic_type = '#39'A1'#39
      '   and datediff(day,a.visit_date,getdate())=0'
      '   and d.p_bar_code = :bar_code'
      ''
      'union'
      ''
      
        'select a.visit_date RegisterDate,a.times VisitNO,a.patient_id+'#39'#' +
        #39'+convert(varchar(10),a.times)  VisitID,case when visit_flag='#39'1'#39 +
        ' then '#39'N'#39' else '#39'Y'#39'  end IsDiagnoses,'
      
        '       a.name PatName,c.name DepName,0 SumFee,b.name DoctName,ca' +
        'se when a.ampm='#39'a'#39' then  '#39#19978#21320#29677#39' else '#39#19979#21320#29677#39' end  ShiftName '
      '  from mz_visit_table a,a_employee_mi b,zd_unit_code c'
      ' where a.gh_doctor *=  b.emp_sn'
      '   and a.gh_dept = c.unit_sn'
      '   and a.visit_flag in ('#39'1'#39')'
      '   and a.clinic_type = '#39'A1'#39
      '   and datediff(day,a.visit_date,getdate())=0'
      '   and a.patient_id  = :pid'
      ''
      ''
      '')
    Left = 600
    Top = 272
  end
  object cdsResponseXml_RegList: TClientDataSet
    Aggregates = <>
    Params = <>
    ProviderName = 'dspGetRegList'
    Left = 800
    Top = 264
    object cdsResponseXml_RegListRegisterDate: TDateTimeField
      FieldName = 'RegisterDate'
      ReadOnly = True
    end
    object cdsResponseXml_RegListVisitNO: TSmallintField
      FieldName = 'VisitNO'
      ReadOnly = True
    end
    object cdsResponseXml_RegListVisitID: TStringField
      FieldName = 'VisitID'
      ReadOnly = True
      Size = 12
    end
    object cdsResponseXml_RegListIsDiagnoses: TStringField
      FieldName = 'IsDiagnoses'
      ReadOnly = True
      Size = 1
    end
    object cdsResponseXml_RegListPatName: TStringField
      FieldName = 'PatName'
      ReadOnly = True
      Size = 60
    end
    object cdsResponseXml_RegListDepName: TStringField
      FieldName = 'DepName'
      ReadOnly = True
      Size = 32
    end
    object cdsResponseXml_RegListSumFee: TIntegerField
      FieldName = 'SumFee'
      ReadOnly = True
    end
    object cdsResponseXml_RegListDoctName: TStringField
      FieldName = 'DoctName'
      ReadOnly = True
      Size = 32
    end
    object cdsResponseXml_RegListShiftName: TStringField
      FieldName = 'ShiftName'
      ReadOnly = True
      Size = 6
    end
  end
  object dspGetRegList: TDataSetProvider
    DataSet = adqGetRegList
    Left = 688
    Top = 272
  end
  object adqCancelReg: TADOQuery
    Connection = adoConn
    CursorType = ctStatic
    Parameters = <
      item
        Name = 'pid'
        DataType = ftString
        NumericScale = 255
        Precision = 255
        Size = 12
        Value = '%'
      end
      item
        Name = 'times'
        DataType = ftString
        NumericScale = 255
        Precision = 255
        Size = 5
        Value = '%'
      end>
    SQL.Strings = (
      'declare @pid char(12),'
      '        @times int'
      ''
      'set @pid = :pid'
      'set @times = :times'
      ''
      'update mz_visit_table set visit_flag = '#39'9'#39
      'where patient_id = @pid'
      '  and times = @times'
      ''
      'delete from mzfz_patient_order'
      'where patient_id = @pid'
      '  and times = @times')
    Left = 600
    Top = 344
  end
end
